package main

import (
	"fmt"
	"reflect"
)

type Data struct {
	weight uint32
	height uint32
}

type Person struct {
	Name string `tips:this is name`
	age  int32  `how old are you?`
	Data
}

func (p *Person) GetName() string {
	return p.Name
}

func (p *Person) GetAge() int32 {
	return p.age
}

func main() {
	p := Person{
		"allen",
		19,
		Data{
			50,
			180,
		},
	}

	v := reflect.ValueOf(p)
	fmt.Println("字段枚举：")
	fmt.Println("------------------------------")
	for i := 0; i < v.NumField(); i++ {
		f := v.Field(i)
		fmt.Printf("index:%d\nvalue:%v\n", i, f)
		fmt.Println("------------------------------")
	}

	fmt.Println("方法枚举：")
	fmt.Println("------------------------------")
	for i := 0; i < v.NumMethod(); i++ {
		m := v.Method(i)
		fmt.Printf("index:%d\nvalue:%v\n", i, m)
		fmt.Println("------------------------------")
	}
}
